<template>
  <c-back-wrap :loading="loading" go-page="经销商营销信息管理" current-page="详情">
    <el-tabs v-model="activeTab" type="card">
      <el-tab-pane name="achive" label="客户档案" lazy>
        <Achive :detail="detail" />
      </el-tab-pane>
      <el-tab-pane name="rewardsAndPunishment" label="奖惩管理" lazy>
        <RewardsAndPunishment :detail="detail" :customer-code="code" />
      </el-tab-pane>
      <el-tab-pane name="prototypeRoom" label="小区样板间" lazy>
        <PrototypeRoom :detail="detail" :customer-code="code" />
      </el-tab-pane>
    </el-tabs>
    <div class="btn-center">
      <c-button type="primary" @click="handleGoBack">返回</c-button>
    </div>
  </c-back-wrap>
</template>
<script>
import { customerDetail } from '@/api/channelTask2/dealerCustomer'
import Achive from './achive'
import RewardsAndPunishment from './rewardsAndPunishment'
import PrototypeRoom from './prototypeRoom'

export default {
  name: 'Detail',
  components: {
    Achive,
    RewardsAndPunishment,
    PrototypeRoom
  },
  props: {
    code: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      detail: {},
      loading: false,
      activeTab: 'achive'
    }
  },
  created() {
    this.getDetailData()
  },
  methods: {
    getDetailData() {
      this.loading = true
      return customerDetail(this.code).then(res => {
        this.detail = res.data
      }).finally(() => {
        this.loading = false
      })
    },
    handleGoBack() {
      this.$pageStack.pop()
    }
  }
}
</script>
